using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum E_PropType
{
    Atk,
    Hp,
    Def,
    Speed,
}
public class PropReward : MonoBehaviour
{
    public E_PropType type = E_PropType.Atk;
    public int changeValue = 10;
    public GameObject getEff;
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            Player player = other.GetComponent<Player>();
            switch (type)
            {
                case E_PropType.Atk:
                    player.atk += changeValue;
                    break;
                case E_PropType.Hp:
                    player.hp += changeValue;
                    if (player.hp > player.maxHp)
                    {
                        player.hp = player.maxHp;
                    }
                    GamePanel.Instance.UpdateHP(player.maxHp, player.hp);
                    break;
                case E_PropType.Def:
                    player.def += changeValue;
                    break;
                case E_PropType.Speed:
                    player.moveSpeed += changeValue;
                    break;
            }
            GameObject eff = Instantiate(getEff, transform.position, transform.rotation);

            AudioSource audioSource = eff.GetComponent<AudioSource>();
            audioSource.volume = GameDataManager.Instance.musicData.soundValue;
            audioSource.mute = GameDataManager.Instance.musicData.isOpenSound;
            Destroy(this.gameObject);
        }

    }
}
